Web Development


Web development become one of the most important programming techniques. This technique
enables you to write server-side applications such as mail servers, discussion groups,
on-line test, message board, guest book, questioniers and any other internet/intranet
database and interactive pages.

With Delphi's Web applications you can build many
client/server applications. The
most nice thing is that you do not need to distribute any application in client side,
because the client application is already exists (Internet Browser) the only thing
you have to distribute is the
URL of your server and it's Aliases.

Delphi can build many types of web server executables such as:
ISAPI/NSAPI DLLs, Win-CGI,
and
CGI stand-alone executable files (Binarry CGI).
There is no main difference in writing CGI, Win-CGI, ISAPI, and NSAPI in Delphi
using web broker technology, but the difference is in the way of it's interaction
with web server and it's techniques in receiving requests and sending responses.


CGI Stand-alone: Is a console application that produce executable file that uses
standard input/ouput system to receive and send data.

Win-CGI: Designed specially for Visual Basic because VB cann't talk directly to
standard input/output system, so that instead the Win-CGI receive and send data using
temporary ini files which causes intensive use of hard disk.

ISAPI/NSAPI: (Internet Server API/Netscape Server API) Both are DLL's that work
with Microsoft servers/Netscape servers respectively. The good news is that Delphi
produce one DLL that can be work with both servers, so that we will refered by ISAPI
to both kinds of DLLs.

Comparison:
The most important difference between ISAPI and CGI is that the server launchs new
instance of the CGI executable for each request, for example if there is a 7 concurrent
users, the server will load 7 instances of the same CGI. This is the most biggest
disadvantage of the CGI, because it leads to memory consumption and reduce server
performance when the request number increased.
ISAPI loads only once in the memory and it serves all the requests, but it creates
separate instances of TWebModule for each request.
The ISAPI is very suitable for large web applications that uses database servers
such as Oracle, and Interbase. When the first request received to the web server,
it loads the ISAPI DLL and open a connection with database server. When the next
request received, there is no need to establish new connection, and the old connection
will be used.

In addition to these advantages of ISAPI, there is a drawback of using it.
Since the ISAPI DLL shared for all requests, unhandled error of one request could
crash the DLL and hangs the server, and no one else can get a response. In most such
cases the DLL must be stopped and started again.
In CGI if an error occures in one request, only it's instance of CGI will be stopped
and the others will resume normally.


Conclusion:

Use CGI:
1. If you are beginner of Web programming
2. At development time
3. In small applications that does not requires connection with Client/Server database
servers
4. When you have few concurrent visitors
5. If you have sensitive server which must not be crashed or hang up.
6. Applications that requires fast response for the single thread.

Use ISAPI/NSAPI:
1. If you need to connect to client/server database system such as Oracle, InterBase,
etc.
2. If you have many concurrent visitors
3. If you can handle all application errors smoothly.
4. If you feel that your CGI application is very slow in response.